<template>
    
    <!-- 组件的模板 -->
    <div class="page">
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <textarea 
                        class="weui-textarea" 
                        placeholder="请输入文本" 
                        rows="4"
                        maxlength="15"
                        v-model="groupName" 
                        minlength="0"
                        style="height:50px"
                    ></textarea>
                    <div class="weui-textarea-counter">
                        <template v-if="groupName">
                            <span v-if="groupName.length">{{groupName.length}}</span>
                            <span v-else>0</span>
                        </template>
                        <template v-else><span>0</span></template>
                        
                        /15
                    </div>
                </div>
            </div>
        </div>
    </div>
        
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import $ from 'zepto'
    import widget from 'gapi/widget.js'
    import cache from 'gapi/cache'
    import * as util from 'js/util.js'
    // import userCenterApi from 'clientApi/userCenterApi'
    // import clientInfo from 'gapi/clientInfo'
    import commonPage from 'clientApi/commonPage.js'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                groupName:''
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                this.groupName = util.getUrddataString('groupName')
                console.log(this.groupName)
            },
            doSave (){
                if(!this.groupName){
                    widget.toast('请输入文本')
                    return
                }
                let editName = {
                    name : this.groupName
                }
                cache.getMemoryCache('editDepartmentWebViewID',(data)=>{
                    if(data){ 
                        commonPage.goBack(1,{'key':'editDepartmentName','value': editName},data.webViewID)
                    }
                })  
            }
        },
        created(){

            this.init();
            /*设置Native的头部*/
            commonPage.updateTitleBar({
                // backAction: 'checkChange',    // 点击返回按钮的动作（即回调函数名称）
                // leftAction: 'checkChange',    // 点击左按钮的动作（即回调函数名称）
                rightDisplay: true,
                rightText: '保存',
                rightAction: 'doSave'
            })
            
            window.doSave = this.doSave
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<!-- <style src="static/css/global.css"></style> -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>



